<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>我的k8s集群</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script src="/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
    <script src="/js/xkube.js?v=1" charset="utf-8"></script>
</head>
<body>
<blockquote class="layui-elem-quote layui-text">
    注:需要在权限管理--集群授权,将集群授权到用户以后,这里才会显示。
</blockquote>
<div class="layuimini-container">
    <div class="layuimini-main">
        <table class="layui-table" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="setDefaultCluster">设为常用集群</a>
        </script>

    </div>
</div>
</body>
<script type="text/html" id="DefaultClusterTpl">
  {{# if (d.cluster_id == getCookie("clusterId")) { }}
     <span style="color:#FF5722">常用集群</span>
	{{# } else { }}
    <span></span>
{{# } }}
</script>	
<script>
    layui.use(['form', 'table','miniTab'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;
            miniTab = layui.miniTab,
            miniTab.listen();

            form.render();

        table.render({
            elem: '#currentTableId',
            url: '/rbac/cluster/MyClusterList'+location.search,
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                //{type: "checkbox", width: 50},
                //{field:'id',width:80,sort: true, title: 'ID'},
      		      {field:'cluster_id',sort: true, title: '集群ID'},
                {field:'cluster_name',sort: true, title: '名称'},
                {field:'kube_version',sort: true, title: '版本'},
      		      {field:'username',sort: true,hide:true, title: '用户'},
                {field: '', title: '默认集群',templet: '#DefaultClusterTpl', width: 100},
                {title: '操作', minWidth: 250, toolbar: '#currentTableBar', align: "center"}
            ]],
            limits: [25, 50, 100],
            limit: 25,
            page: true
        });

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'setDefaultCluster') {
                setCookie('clusterId',data.cluster_id,30);
                layer.msg('设置成功');
                window.location.reload();                               
            }
        });

    });
</script>
</html>